// pages/downloading/downloading.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isDown: false,
    totalBytesExpectedToWrite: 0,
    totalBytesWritten: 0,
    progress: 0
  },

  //下载文件
  download: function () {
    var that = this
    // var url = "https://qiniu-ecdn.dcloud.net.cn/download/HBuilderX.3.99.2023122611.zip"
    var url = "https://www.voidtools.com/Everything-1.4.1.1024.x86-Setup.exe"
    const downTask = wx.downloadFile({
      url: url,
      success: function (res) {
        console.log(res)
      }
    })
    downTask.onProgressUpdate(function (res) {
      console.log(res)
      that.setData({
        totalBytesExpectedToWrite: res.totalBytesExpectedToWrite,
        totalBytesWritten: res.totalBytesWritten,
        progress: res.progress,
        isDown: true
      })
      // if (res.progress > 33) {
      //   // downTask.abort()
      // }
    })
  },

})